<?php
  require_once('./db.php');

  if(isset($_POST['name']) && !empty($_POST['name'])) {
    $_POST['added_date'] = date('Y-m-d H:i:s');
    $_POST['status'] = '1';
    pr($_POST);

    $query = "INSERT INTO `users` SET ";
    $tmp = '';
    foreach($_POST as $colName=>$value) {
      $tmp .= "`$colName`='$value' ,";
    }
    $tmp = rtrim($tmp, ' ,');
    $query = $query.$tmp;
    pq($query);
    mysql_query($query) or die(mysql_error());
    $id = mysql_insert_id();
    echo "Record inserted on ID <strong></strong>$id</strong>";
  }
?>
<form action="" method="post">
  <table  border="1" cellpadding="0" cellspacing="0" width="80%" align="center">
    <thead>
      <tr>
        <th colspan="2">Please add user</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="right">Name :</td>
        <td><input required type="text" name="name"/></td>
      </tr>
      <tr>
        <td align="right">Email :</td>
        <td><input required type="email" name="email"/></td>
      </tr>
      <tr>
        <td align="right">Password :</td>
        <td><input required type="password" name="password"/></td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td><input type="submit" value="I am done!!" /></td>
      </tr>
    </tbody>
  </table>

</form>
